<?php

###########################################################################
#   Copyright (C) 2012 CDNPAL LTD by Christopher Gu                       #
#   resources@cdnpal.com                                                  #
#                                                                         #
#   coded for Php 4.3/5.X and above                                       #
#   and AllowOverride all for .htaccess                                   #
#                                                                         #
#   This program is free software released                                #
#   under the GPL version 2 license:                                      #
#   http://www.gnu.org/licenses/gpl-2.0.htm                               #
#                                                                         #
#   This program is distributed WITHOUT ANY WARRANTY                      #
#   or FITNESS FOR A PARTICULAR PURPOSE.                                  #
#                                                                         #
#   DADF-SDK                                                              #
#                                                                         #
###########################################################################

class BuysideController extends Zend_Rest_Controller
{
    public function init()
    {
        $this->_helper->viewRenderer->setNoRender(true);
    }

    public function getAction()
    {
    	$this->getResponse()
    	->setHttpResponseCode(403)
    	->appendBody(json_encode(array("status"=>"error", "message"=>"forbidden - dadf server is post only")));
    	
    }

 	public function indexAction()
    {	
    	$this->getResponse()
    	->setHttpResponseCode(403)
    	->appendBody(json_encode(array("status"=>"error", "message"=>"forbidden - dadf server is post only")));
    }
    
    public function postAction()
    {
    	
       	$request = $this->getRequest();
    
    	$action = $request->getParam('id');
    	
    	
    	$response_success = array("status"=>"success");
    	$response_failure = array("status"=>"failed");
    	
    	$response = $response_success;
    	
    	switch ($action):
    	
    		case "dadfrequest":
    			BuysideService::process_dadf_request($request);
    			break;
         	
       		case "dadfaccept":
				BuysideService::process_dadf_accept($request);	
         		break;
         		
         	default:
         	
		    	$this->getResponse()
		    	->setHttpResponseCode(400)
		    	->appendBody(json_encode(array("status"=>"error", "message"=>"Bad Request: types are dadfrequest and dadfaccept only")));		
         		break;
    	
    	endswitch;

    }
    
    public function putAction()
    {
    	$this->postAction();
    }
    
    public function deleteAction()
    {
    	$this->getResponse()
    	->setHttpResponseCode(403)
    	->appendBody(json_encode(array("status"=>"error", "message"=>"forbidden - dadf server is post only")));
    }


}

